<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: ActiveTest::Controller</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">ActiveTest::Controller</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../files/lib/active_test/subject/controller_rb.html">
                lib/active_test/subject/controller.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                <a href="Subject.html">
                Subject
               </a>
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
<a href="Controller.html">ActiveTest::Controller</a> is probably going to
be the most-used <a href="Subject.html">Subject</a> in your tests. It
specifies the most common situations of a controller, namely restful CRUD,
and helps you test the behaviour of the 7 most common actions: index, show,
new, create, edit, update and destroy.
</p>
<h2>Setup</h2>
<p>
Probably the most useful class method you can call to dry up your
controller is the deadly one-liner, <a
href="Controller.html#M000018">setup_controller</a>. It does a number of
things, including setting up a bunch of inflector values for your
controller and the model assumed to be managed by it. You get all these
instance variables for free in your test:
</p>
<pre>
  @request and @response
  @controller, @controller_name, @controller_class
  @model, @model_name, @model_class, @model_singular, @model_plural
</pre>
<p>
The model instance variables are then used for assuming certain instance
variables are assigned by your controller. For example, if you use a
dynamic method (see below) for the index action in your FriendsController,
it will automatically look for @friends in your template. You can use these
instance variables throughout your edge case tests too.
</p>
<h2>Expectations &amp; Assumptions</h2>
<p>
Request Method Assumptions:
</p>
<pre>
  index, show, new and edit all use the GET HTTP request method.
  create uses the POST HTTP request method.
  update uses the PUT HTTP request method.
  destroy uses the DELETE HTTP request method.
</pre>
<p>
Any other action is assumed to be a collector just like index.
</p>
<p>
Response Behaviour:
</p>
<pre>
  GET requests return 200 on success, 404 on failure or not found.
  POST requests redirect on success, 200 on failure.
  PUT requests redirect on success, 200 on failure, 404 if not found.
  DELETE requests redirect on success, 404 on failure.
</pre>
<p>
If you do not use the standard
<tt>ActiveRecord::Base.find(params[:id])</tt>, expecting an
ActiveRecord::RecordNotFound exception for non-existent records, there is
an option for this situation and, in fact, most unconventional paths, like
different failure/success responses and request methods.
</p>
<h2>Dynamic Methods</h2>
<p>
<a href="Controller.html">ActiveTest::Controller</a> has three dynamic
methods: responds_with, fails_on and should. The first two follow this
pattern:
</p>
<pre>
    test_*_responds_with_*
    test_*_fails_to_*
</pre>
<p>
The first wildcard is the name of your action, and the second wild card is
one of the seven CRUD operations:
</p>
<pre>
    index_items
    show_item
    new_item
    create_item
    edit_item
    update_item
    destroy_item
</pre>
<p>
For example:
</p>
<pre>
  test_index_responds_with_index_items
  test_create_fails_to_create_item :redirect =&gt; :index_url
</pre>
<p>
Assuming your controller is called FriendsController, these two dynamic
methods will create the following tests:
</p>
<pre>
  def test_should_index_items
    get :index
    assert_response :success
    assert_template 'index'
    assert_assigned :friends
  end
  def test_should_new_item
    post :create
    assert_response :success
    assert_template 'new'
    assert_assigned :friend
  end
</pre>
<p>
Remember the seven operations? There is a third dynamic method that uses
just them:
</p>
<pre>
    test_should_*
</pre>
<p>
If you use <tt>test_should_index_items</tt>, for example, it will assume
the index action.
</p>
<h2>Dynamic Method Options</h2>
<pre>
 TO BE WRITTEN
</pre>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000039">assert_delete_success</a>&nbsp;&nbsp;
      <a href="#M000036">assert_get_success</a>&nbsp;&nbsp;
      <a href="#M000037">assert_post_success</a>&nbsp;&nbsp;
      <a href="#M000038">assert_put_success</a>&nbsp;&nbsp;
      <a href="#M000033">create_item</a>&nbsp;&nbsp;
      <a href="#M000035">destroy_item</a>&nbsp;&nbsp;
      <a href="#M000028">determine_request_method</a>&nbsp;&nbsp;
      <a href="#M000032">edit_item</a>&nbsp;&nbsp;
      <a href="#M000029">index_items</a>&nbsp;&nbsp;
      <a href="#M000027">method_missing</a>&nbsp;&nbsp;
      <a href="#M000040">method_missing</a>&nbsp;&nbsp;
      <a href="#M000031">new_item</a>&nbsp;&nbsp;
      <a href="#M000018">setup_controller</a>&nbsp;&nbsp;
      <a href="#M000030">show_item</a>&nbsp;&nbsp;
      <a href="#M000019">test_actions_succeed</a>&nbsp;&nbsp;
      <a href="#M000024">test_create_action_succeeds</a>&nbsp;&nbsp;
      <a href="#M000026">test_destroy_action_succeeds</a>&nbsp;&nbsp;
      <a href="#M000023">test_edit_action_succeeds</a>&nbsp;&nbsp;
      <a href="#M000020">test_index_action_succeeds</a>&nbsp;&nbsp;
      <a href="#M000022">test_new_action_succeeds</a>&nbsp;&nbsp;
      <a href="#M000021">test_show_action_succeeds</a>&nbsp;&nbsp;
      <a href="#M000025">test_update_action_succeeds</a>&nbsp;&nbsp;
      <a href="#M000034">update_item</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000027" class="method-detail">
        <a name="M000027"></a>

        <div class="method-heading">
          <a href="#M000027" class="method-signature">
          <span class="method-name">method_missing</span><span class="method-args">(method_name, *args)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000027-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000027-source">
<pre>
     <span class="ruby-comment cmt"># File lib/active_test/subject/controller.rb, line 167</span>
167:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">method_missing</span>(<span class="ruby-identifier">method_name</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
168:         <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">method_name</span>.<span class="ruby-identifier">to_s</span>
169:         <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/^test_(\w+)_should_(\w+)_(\w+)$/</span>
170:           <span class="ruby-identifier">action</span>, <span class="ruby-identifier">method</span>, <span class="ruby-identifier">spec</span> = <span class="ruby-identifier">$1</span>, <span class="ruby-identifier">$2</span>, <span class="ruby-node">&quot;#{$2}_#{$3}&quot;</span>
171:           <span class="ruby-identifier">parameters</span> = (<span class="ruby-identifier">args</span>.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">pop</span> <span class="ruby-operator">:</span> {})
172:           <span class="ruby-identifier">spec</span> = <span class="ruby-identifier">method</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">action</span> <span class="ruby-value">? </span><span class="ruby-identifier">spec</span> <span class="ruby-operator">:</span> <span class="ruby-node">&quot;#{spec}_for_#{action}&quot;</span>
173:           <span class="ruby-identifier">define_method</span>(<span class="ruby-node">&quot;test_should_#{spec}&quot;</span>) { <span class="ruby-identifier">send</span> <span class="ruby-identifier">spec</span>, <span class="ruby-identifier">action</span>, <span class="ruby-identifier">parameters</span> }
174:         <span class="ruby-keyword kw">else</span>
175:           <span class="ruby-keyword kw">super</span>
176:         <span class="ruby-keyword kw">end</span>
177:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000018" class="method-detail">
        <a name="M000018"></a>

        <div class="method-heading">
          <a href="#M000018" class="method-signature">
          <span class="method-name">setup_controller</span><span class="method-args">(options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Sets up a test suite for testing a controller.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000018-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000018-source">
<pre>
     <span class="ruby-comment cmt"># File lib/active_test/subject/controller.rb, line 99</span>
 99:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">setup_controller</span>(<span class="ruby-identifier">options</span> = {})
100:         <span class="ruby-identifier">controller</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">name</span>[<span class="ruby-regexp re">/^(\w+)Test/</span>, <span class="ruby-value">1</span>]
101:         <span class="ruby-identifier">controller_path</span> = (<span class="ruby-identifier">controller</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;ApplicationController&quot;</span> <span class="ruby-operator">?</span> <span class="ruby-value str">&quot;Application&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">controller</span>).<span class="ruby-identifier">underscore</span>
102:         <span class="ruby-identifier">require</span> <span class="ruby-identifier">controller_path</span>.<span class="ruby-identifier">underscore</span>
103:         <span class="ruby-identifier">define_method</span>(<span class="ruby-identifier">:setup</span>) <span class="ruby-keyword kw">do</span>
104:           <span class="ruby-ivar">@controller_name</span> = <span class="ruby-identifier">controller</span>
105:           <span class="ruby-ivar">@model_name</span> = <span class="ruby-ivar">@controller_name</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-value str">'Controller'</span>, <span class="ruby-value str">''</span>).<span class="ruby-identifier">singularize</span>
106:           <span class="ruby-ivar">@model_singular</span>, <span class="ruby-ivar">@model_plural</span> = <span class="ruby-ivar">@model_name</span>.<span class="ruby-identifier">underscore</span>, <span class="ruby-ivar">@model_name</span>.<span class="ruby-identifier">underscore</span>.<span class="ruby-identifier">pluralize</span>
107:           <span class="ruby-ivar">@controller_class</span> = <span class="ruby-ivar">@controller_name</span>.<span class="ruby-identifier">constantize</span> <span class="ruby-comment cmt"># must have one</span>
108:           <span class="ruby-ivar">@model_class</span> = <span class="ruby-ivar">@model_name</span>.<span class="ruby-identifier">constantize</span> <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-comment cmt"># for edge cases</span>
109: 
110:           <span class="ruby-ivar">@model</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:model</span>) <span class="ruby-operator">||</span> <span class="ruby-ivar">@model_class</span>
111:           <span class="ruby-ivar">@controller</span> = <span class="ruby-ivar">@controller_class</span>.<span class="ruby-identifier">new</span>
112:           <span class="ruby-ivar">@request</span>    = <span class="ruby-constant">ActionController</span><span class="ruby-operator">::</span><span class="ruby-constant">TestRequest</span>.<span class="ruby-identifier">new</span>
113:           <span class="ruby-ivar">@response</span>   = <span class="ruby-constant">ActionController</span><span class="ruby-operator">::</span><span class="ruby-constant">TestResponse</span>.<span class="ruby-identifier">new</span>
114:           <span class="ruby-identifier">login_as</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:login_as</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:login_as</span>]
115:         <span class="ruby-keyword kw">end</span>
116:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000019" class="method-detail">
        <a name="M000019"></a>

        <div class="method-heading">
          <a href="#M000019" class="method-signature">
          <span class="method-name">test_actions_succeed</span><span class="method-args">(*actions)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000019-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000019-source">
<pre>
     <span class="ruby-comment cmt"># File lib/active_test/subject/controller.rb, line 118</span>
118:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">test_actions_succeed</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">actions</span>)
119:         <span class="ruby-identifier">parameters</span> = <span class="ruby-identifier">actions</span>.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">actions</span>.<span class="ruby-identifier">pop</span> <span class="ruby-operator">:</span> {}
120:         [<span class="ruby-identifier">actions</span>].<span class="ruby-identifier">flatten</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">action</span><span class="ruby-operator">|</span>
121:           <span class="ruby-identifier">send</span> <span class="ruby-node">&quot;test_#{action}_action_succeeds&quot;</span>.<span class="ruby-identifier">to_sym</span>, <span class="ruby-identifier">parameters</span>
122:         <span class="ruby-keyword kw">end</span>
123:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000024" class="method-detail">
        <a name="M000024"></a>

        <div class="method-heading">
          <a href="#M000024" class="method-signature">
          <span class="method-name">test_create_action_succeeds</span><span class="method-args">(model, parameters = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000024-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000024-source">
<pre>
     <span class="ruby-comment cmt"># File lib/active_test/subject/controller.rb, line 149</span>
149:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">test_create_action_succeeds</span>(<span class="ruby-identifier">model</span>, <span class="ruby-identifier">parameters</span> = {})
150:         <span class="ruby-identifier">define_method</span>(<span class="ruby-value str">&quot;test_should_create_item&quot;</span>) <span class="ruby-keyword kw">do</span>
151:           <span class="ruby-identifier">assert_create_action_success</span> <span class="ruby-identifier">parameters</span>
152:         <span class="ruby-keyword kw">end</span>
153:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000026" class="method-detail">
        <a name="M000026"></a>

        <div class="method-heading">
          <a href="#M000026" class="method-signature">
          <span class="method-name">test_destroy_action_succeeds</span><span class="method-args">(model, parameters = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000026-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000026-source">
<pre>
     <span class="ruby-comment cmt"># File lib/active_test/subject/controller.rb, line 161</span>
161:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">test_destroy_action_succeeds</span>(<span class="ruby-identifier">model</span>, <span class="ruby-identifier">parameters</span> = {})
162:         <span class="ruby-identifier">define_method</span>(<span class="ruby-value str">&quot;test_should_destroy_item&quot;</span>) <span class="ruby-keyword kw">do</span>
163:           <span class="ruby-identifier">assert_destroy_action_success</span> <span class="ruby-identifier">parameters</span>
164:         <span class="ruby-keyword kw">end</span>
165:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000023" class="method-detail">
        <a name="M000023"></a>

        <div class="method-heading">
          <a href="#M000023" class="method-signature">
          <span class="method-name">test_edit_action_succeeds</span><span class="method-args">(parameters = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000023-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000023-source">
<pre>
     <span class="ruby-comment cmt"># File lib/active_test/subject/controller.rb, line 143</span>
143:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">test_edit_action_succeeds</span>(<span class="ruby-identifier">parameters</span> = {})
144:         <span class="ruby-identifier">define_method</span>(<span class="ruby-value str">&quot;test_should_present_form_for_edit&quot;</span>) <span class="ruby-keyword kw">do</span>
145:           <span class="ruby-identifier">assert_edit_action_success</span> <span class="ruby-identifier">parameters</span>
146:         <span class="ruby-keyword kw">end</span>
147:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000020" class="method-detail">
        <a name="M000020"></a>

        <div class="method-heading">
          <a href="#M000020" class="method-signature">
          <span class="method-name">test_index_action_succeeds</span><span class="method-args">(parameters = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000020-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000020-source">
<pre>
     <span class="ruby-comment cmt"># File lib/active_test/subject/controller.rb, line 125</span>
125:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">test_index_action_succeeds</span>(<span class="ruby-identifier">parameters</span> = {})
126:         <span class="ruby-identifier">define_method</span>(<span class="ruby-value str">&quot;test_should_list_items&quot;</span>) <span class="ruby-keyword kw">do</span>
127:           <span class="ruby-identifier">assert_index_action_success</span> <span class="ruby-identifier">parameters</span>
128:         <span class="ruby-keyword kw">end</span>
129:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000022" class="method-detail">
        <a name="M000022"></a>

        <div class="method-heading">
          <a href="#M000022" class="method-signature">
          <span class="method-name">test_new_action_succeeds</span><span class="method-args">(parameters = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000022-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000022-source">
<pre>
     <span class="ruby-comment cmt"># File lib/active_test/subject/controller.rb, line 137</span>
137:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">test_new_action_succeeds</span>(<span class="ruby-identifier">parameters</span> = {})
138:         <span class="ruby-identifier">define_method</span>(<span class="ruby-value str">&quot;test_should_present_form_for_new&quot;</span>) <span class="ruby-keyword kw">do</span>
139:           <span class="ruby-identifier">assert_new_action_success</span> <span class="ruby-identifier">parameters</span>
140:         <span class="ruby-keyword kw">end</span>
141:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000021" class="method-detail">
        <a name="M000021"></a>

        <div class="method-heading">
          <a href="#M000021" class="method-signature">
          <span class="method-name">test_show_action_succeeds</span><span class="method-args">(parameters = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000021-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000021-source">
<pre>
     <span class="ruby-comment cmt"># File lib/active_test/subject/controller.rb, line 131</span>
131:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">test_show_action_succeeds</span>(<span class="ruby-identifier">parameters</span> = {})
132:         <span class="ruby-identifier">define_method</span>(<span class="ruby-value str">&quot;test_should_show_item&quot;</span>) <span class="ruby-keyword kw">do</span>
133:           <span class="ruby-identifier">assert_show_action_success</span> <span class="ruby-identifier">parameters</span>
134:         <span class="ruby-keyword kw">end</span>
135:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000025" class="method-detail">
        <a name="M000025"></a>

        <div class="method-heading">
          <a href="#M000025" class="method-signature">
          <span class="method-name">test_update_action_succeeds</span><span class="method-args">(model, parameters = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000025-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000025-source">
<pre>
     <span class="ruby-comment cmt"># File lib/active_test/subject/controller.rb, line 155</span>
155:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">test_update_action_succeeds</span>(<span class="ruby-identifier">model</span>, <span class="ruby-identifier">parameters</span> = {})
156:         <span class="ruby-identifier">define_method</span>(<span class="ruby-value str">&quot;test_should_update_item&quot;</span>) <span class="ruby-keyword kw">do</span>
157:           <span class="ruby-identifier">assert_update_action_success</span> <span class="ruby-identifier">parameters</span>
158:         <span class="ruby-keyword kw">end</span>
159:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Protected Class methods</h3>

      <div id="method-M000028" class="method-detail">
        <a name="M000028"></a>

        <div class="method-heading">
          <a href="#M000028" class="method-signature">
          <span class="method-name">determine_request_method</span><span class="method-args">(action)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000028-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000028-source">
<pre>
     <span class="ruby-comment cmt"># File lib/active_test/subject/controller.rb, line 181</span>
181:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">determine_request_method</span>(<span class="ruby-identifier">action</span>)
182:         <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">action</span>.<span class="ruby-identifier">to_s</span>
183:         <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/destroy|delete/</span> <span class="ruby-keyword kw">then</span> <span class="ruby-identifier">:delete</span>
184:         <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/update/</span> <span class="ruby-keyword kw">then</span> <span class="ruby-identifier">:put</span>
185:         <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/create/</span> <span class="ruby-keyword kw">then</span> <span class="ruby-identifier">:post</span>
186:         <span class="ruby-keyword kw">else</span> <span class="ruby-identifier">:get</span>
187:         <span class="ruby-keyword kw">end</span>
188:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000039" class="method-detail">
        <a name="M000039"></a>

        <div class="method-heading">
          <a href="#M000039" class="method-signature">
          <span class="method-name">assert_delete_success</span><span class="method-args">(action, parameters = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000039-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000039-source">
<pre>
     <span class="ruby-comment cmt"># File lib/active_test/subject/controller.rb, line 246</span>
246:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">assert_delete_success</span>(<span class="ruby-identifier">action</span>, <span class="ruby-identifier">parameters</span> = {})
247:       <span class="ruby-identifier">redirect</span> = <span class="ruby-identifier">parameters</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:redirect</span>)
248:       <span class="ruby-identifier">delete</span> <span class="ruby-identifier">action</span>, <span class="ruby-identifier">parameters</span>
249:       <span class="ruby-identifier">assert_response</span> <span class="ruby-identifier">:redirect</span>
250:       <span class="ruby-identifier">assert_redirected_to</span> <span class="ruby-identifier">redirect</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">redirect</span>
251:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000036" class="method-detail">
        <a name="M000036"></a>

        <div class="method-heading">
          <a href="#M000036" class="method-signature">
          <span class="method-name">assert_get_success</span><span class="method-args">(action, parameters = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000036-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000036-source">
<pre>
     <span class="ruby-comment cmt"># File lib/active_test/subject/controller.rb, line 226</span>
226:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">assert_get_success</span>(<span class="ruby-identifier">action</span>, <span class="ruby-identifier">parameters</span> = {})
227:       <span class="ruby-identifier">get</span> <span class="ruby-identifier">action</span>
228:       <span class="ruby-identifier">assert_response</span> <span class="ruby-identifier">:success</span>
229:       <span class="ruby-identifier">assert_template</span> <span class="ruby-identifier">action</span>.<span class="ruby-identifier">to_s</span>
230:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000037" class="method-detail">
        <a name="M000037"></a>

        <div class="method-heading">
          <a href="#M000037" class="method-signature">
          <span class="method-name">assert_post_success</span><span class="method-args">(action, parameters = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000037-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000037-source">
<pre>
     <span class="ruby-comment cmt"># File lib/active_test/subject/controller.rb, line 232</span>
232:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">assert_post_success</span>(<span class="ruby-identifier">action</span>, <span class="ruby-identifier">parameters</span> = {})
233:       <span class="ruby-identifier">redirect</span> = <span class="ruby-identifier">parameters</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:redirect</span>)
234:       <span class="ruby-identifier">post</span> <span class="ruby-identifier">action</span>, <span class="ruby-identifier">parameters</span>
235:       <span class="ruby-identifier">assert_response</span> <span class="ruby-identifier">:redirect</span>
236:       <span class="ruby-identifier">assert_redirected_to</span> <span class="ruby-identifier">redirect</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">redirect</span>
237:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000038" class="method-detail">
        <a name="M000038"></a>

        <div class="method-heading">
          <a href="#M000038" class="method-signature">
          <span class="method-name">assert_put_success</span><span class="method-args">(action, parameters = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000038-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000038-source">
<pre>
     <span class="ruby-comment cmt"># File lib/active_test/subject/controller.rb, line 239</span>
239:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">assert_put_success</span>(<span class="ruby-identifier">action</span>, <span class="ruby-identifier">parameters</span> = {})
240:       <span class="ruby-identifier">redirect</span> = <span class="ruby-identifier">parameters</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:redirect</span>)
241:       <span class="ruby-identifier">put</span> <span class="ruby-identifier">action</span>, <span class="ruby-identifier">parameters</span>
242:       <span class="ruby-identifier">assert_response</span> <span class="ruby-identifier">:redirect</span>
243:       <span class="ruby-identifier">assert_redirected_to</span> <span class="ruby-identifier">redirect</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">redirect</span>
244:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000033" class="method-detail">
        <a name="M000033"></a>

        <div class="method-heading">
          <a href="#M000033" class="method-signature">
          <span class="method-name">create_item</span><span class="method-args">(action, parameters = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000033-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000033-source">
<pre>
     <span class="ruby-comment cmt"># File lib/active_test/subject/controller.rb, line 216</span>
216:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">create_item</span>(<span class="ruby-identifier">action</span>, <span class="ruby-identifier">parameters</span> = {})
217:       <span class="ruby-identifier">assert_post_success</span>(<span class="ruby-identifier">action</span>, <span class="ruby-identifier">parameters</span>)
218:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000035" class="method-detail">
        <a name="M000035"></a>

        <div class="method-heading">
          <a href="#M000035" class="method-signature">
          <span class="method-name">destroy_item</span><span class="method-args">(action, parameters = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000035-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000035-source">
<pre>
     <span class="ruby-comment cmt"># File lib/active_test/subject/controller.rb, line 222</span>
222:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">destroy_item</span>(<span class="ruby-identifier">action</span>, <span class="ruby-identifier">parameters</span> = {})
223:       <span class="ruby-identifier">assert_delete_success</span>(<span class="ruby-identifier">action</span>, <span class="ruby-identifier">parameters</span>)
224:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000032" class="method-detail">
        <a name="M000032"></a>

        <div class="method-heading">
          <a href="#M000032" class="method-signature">
          <span class="method-name">edit_item</span><span class="method-args">(action, parameters = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000032-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000032-source">
<pre>
     <span class="ruby-comment cmt"># File lib/active_test/subject/controller.rb, line 209</span>
209:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">edit_item</span>(<span class="ruby-identifier">action</span>, <span class="ruby-identifier">parameters</span> = {})
210:       <span class="ruby-identifier">ivar</span> = (<span class="ruby-identifier">parameters</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:instance</span>) <span class="ruby-operator">||</span> <span class="ruby-ivar">@model_singular</span>).<span class="ruby-identifier">to_sym</span>
211:       <span class="ruby-identifier">expected_value</span> = <span class="ruby-identifier">parameters</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:expect</span>) <span class="ruby-operator">||</span> <span class="ruby-keyword kw">nil</span>
212:       <span class="ruby-identifier">assert_get_success</span>(<span class="ruby-identifier">action</span>, <span class="ruby-identifier">parameters</span>)
213:       <span class="ruby-identifier">assert_assigned</span> <span class="ruby-identifier">ivar</span>, <span class="ruby-identifier">expected_value</span>
214:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000029" class="method-detail">
        <a name="M000029"></a>

        <div class="method-heading">
          <a href="#M000029" class="method-signature">
          <span class="method-name">index_items</span><span class="method-args">(action, parameters = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000029-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000029-source">
<pre>
     <span class="ruby-comment cmt"># File lib/active_test/subject/controller.rb, line 192</span>
192:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">index_items</span>(<span class="ruby-identifier">action</span>, <span class="ruby-identifier">parameters</span> = {})
193:       <span class="ruby-identifier">ivar</span> = (<span class="ruby-identifier">parameters</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:instance</span>) <span class="ruby-operator">||</span> <span class="ruby-ivar">@model_plural</span>).<span class="ruby-identifier">to_sym</span>
194:       <span class="ruby-identifier">assert_get_success</span>(<span class="ruby-identifier">action</span>, <span class="ruby-identifier">parameters</span>)
195:       <span class="ruby-identifier">assert_assigned</span> <span class="ruby-identifier">ivar</span>
196:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000040" class="method-detail">
        <a name="M000040"></a>

        <div class="method-heading">
          <a href="#M000040" class="method-signature">
          <span class="method-name">method_missing</span><span class="method-args">(method_name, *args)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000040-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000040-source">
<pre>
     <span class="ruby-comment cmt"># File lib/active_test/subject/controller.rb, line 253</span>
253:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">method_missing</span>(<span class="ruby-identifier">method_name</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
254:       <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">method_name</span>.<span class="ruby-identifier">to_s</span>
255:       <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/^assert_(\w+)_action_success$/</span>
256:         <span class="ruby-identifier">action</span>, <span class="ruby-identifier">parameters</span> = <span class="ruby-identifier">$1</span>, (<span class="ruby-identifier">args</span>.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">pop</span> <span class="ruby-operator">:</span> {})
257:         <span class="ruby-identifier">send</span> <span class="ruby-node">&quot;assert_#{self.class.determine_request_method(action)}_success&quot;</span>, <span class="ruby-identifier">action</span>, <span class="ruby-identifier">parameters</span>
258:       <span class="ruby-keyword kw">else</span>
259:         <span class="ruby-keyword kw">super</span>
260:       <span class="ruby-keyword kw">end</span>
261:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000031" class="method-detail">
        <a name="M000031"></a>

        <div class="method-heading">
          <a href="#M000031" class="method-signature">
          <span class="method-name">new_item</span><span class="method-args">(action, parameters = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000031-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000031-source">
<pre>
     <span class="ruby-comment cmt"># File lib/active_test/subject/controller.rb, line 204</span>
204:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">new_item</span>(<span class="ruby-identifier">action</span>, <span class="ruby-identifier">parameters</span> = {})
205:       <span class="ruby-identifier">ivar</span> = (<span class="ruby-identifier">parameters</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:instance</span>) <span class="ruby-operator">||</span> <span class="ruby-ivar">@model_singular</span>).<span class="ruby-identifier">to_sym</span>
206:       <span class="ruby-identifier">assert_get_success</span>(<span class="ruby-identifier">action</span>, <span class="ruby-identifier">parameters</span>)
207:       <span class="ruby-identifier">assert_assigned</span> <span class="ruby-identifier">ivar</span>
208:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000030" class="method-detail">
        <a name="M000030"></a>

        <div class="method-heading">
          <a href="#M000030" class="method-signature">
          <span class="method-name">show_item</span><span class="method-args">(action, parameters = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000030-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000030-source">
<pre>
     <span class="ruby-comment cmt"># File lib/active_test/subject/controller.rb, line 198</span>
198:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">show_item</span>(<span class="ruby-identifier">action</span>, <span class="ruby-identifier">parameters</span> = {})
199:       <span class="ruby-identifier">ivar</span> = (<span class="ruby-identifier">parameters</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:instance</span>) <span class="ruby-operator">||</span> <span class="ruby-ivar">@model_singular</span>).<span class="ruby-identifier">to_sym</span>
200:       <span class="ruby-identifier">expected_value</span> = <span class="ruby-identifier">parameters</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:expect</span>) <span class="ruby-operator">||</span> <span class="ruby-keyword kw">nil</span>
201:       <span class="ruby-identifier">assert_get_success</span>(<span class="ruby-identifier">action</span>, <span class="ruby-identifier">parameters</span>)
202:       <span class="ruby-identifier">assert_assigned</span> <span class="ruby-identifier">ivar</span>, <span class="ruby-identifier">expected_value</span>
203:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000034" class="method-detail">
        <a name="M000034"></a>

        <div class="method-heading">
          <a href="#M000034" class="method-signature">
          <span class="method-name">update_item</span><span class="method-args">(action, parameters = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000034-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000034-source">
<pre>
     <span class="ruby-comment cmt"># File lib/active_test/subject/controller.rb, line 219</span>
219:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">update_item</span>(<span class="ruby-identifier">action</span>, <span class="ruby-identifier">parameters</span> = {})
220:       <span class="ruby-identifier">assert_put_success</span>(<span class="ruby-identifier">action</span>, <span class="ruby-identifier">parameters</span>)
221:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>